const people = new Map();
people.set('jelly', 16)
people.set('mary', 16)
people.set('mike', 15)
people.set('luffy', 15)
people.set({}, 15)
console.log(people);
console.log(people.get('luffy'));
console.log(people.size);
console.log(people.has('mary'));
people.delete('mike')
console.log(people);
// people.clear();

people.forEach((key, value, map) => {
    console.log(key, value, map);
})

for (const student of people) {
    console.log(student);
}

for (const [key, value] of people) {
    console.log(key, value);
}

const fruits = new Map([['apple', 6], ['peach', 7]]);
console.log(fruits);

const clickCounts = new Map();
const btns = document.querySelectorAll('button');

btns.forEach(button => {
    clickCounts.set(button, 0);
    button.addEventListener('click', function () {
        const val = clickCounts.get(this);
        clickCounts.set(this, val + 1);
        console.log(clickCounts);
    })
})

// WeakMap
let jelly = { name: 'jelly' };
let luffy = { name: 'luffy' };

const strong = new Map();
const weak = new WeakMap();

strong.set(jelly, 'jelly is a girl!');
weak.set(luffy, 'luffy is a boy!');

console.log(strong);
console.log(weak);

console.log(strong.size);
console.log(weak.size);

jelly = null;
luffy = null;
console.log(strong);
console.log(weak);